1. Technical Field
The present invention relates to an encoding apparatus, an encoding method, an encoding program, and an imaging apparatus applied to compress for example a picture signal.
2. Background Art
An imaging apparatus such as a digital still camera often performs a picture process such as a picture distortion correction process, a chromatic aberration correction process, a picture size enlargement process or a picture size reduction process. In addition, such an apparatus often compresses picture data generated in a picture process according to a compression-encoding process such as JPEG (Joint Photographic Experts Group) or MPEG (Moving Picture Experts Group Phase). In these compression-encoding processes, picture data are encoded in the unit of a picture called a macroblock.
To perform a picture process, for example an interpolation process is performed for picture data that are read from a memory. To encode picture data, the size of an area whose picture size has been changed is set to the size of a macroblock. In such a picture size changing process, since the picture size is changed to a small size for example the size of a macroblock, it is necessary to read picture data at high speed.
Moreover, in such a picture process, not only picture data of an area to be processed, but picture data of a filtering area adjacent thereto are often used. In this case, a picture process can be more effectively performed in the unit of a larger block than in the unit of a smaller block. With reference to FIG. 1A, FIG. 1B, and FIG. 1C, this point will be described.
FIG. 1A shows an example of which a picture process is performed in the unit of (8 pixels×8 pixels) as a hatched area. Assuming that it is necessary to use an area of 2 pixels×2 pixels in the vertical and horizontal directions in the process, the number of pixels processed is 64 and the number of pixels effectively processed is (4 pixels×4 pixels=16 pixels). Thus, the efficiency (number of pixels effectively processed/number of pixels processed=25%). FIG. 1B shows the case of which the block size is (128 pixels×128 pixels=16384 pixels). In this case, the number of pixels processed is 16384 pixels, the number of pixels effectively processed is (124 pixels×124 pixels=15376 pixels), and the efficiency becomes 93%. FIG. 1C shows an example of a horizontally oblong block, for example (2048 pixels×8 pixels=16384 pixels). In this case, the number of pixels effectively processed is (2044 pixels×4 pixels=8176 pixels) and the efficiency becomes 49%. FIG. 1A, FIG. 1B, and FIG. 1C show an example of which one picture is composed of a multiple of the process unit of (3×3=9).
FIG. 2 shows an example of which data for which a picture process has been performed are encoded according to for example JPEG. In FIG. 2, one picture is composed of (4×2) macroblocks. When a picture process is performed in the unit of four macroblocks that are horizontally arranged, since their order matches the encoding direction defined in JPEG, data obtained in the picture process are successively transferred to a JPEG encoder and encoded thereby.
In FIG. 2, since the picture process unit is a horizontally oblong area, as shown in FIG. 3, it is assumed that a picture process is performed in the unit of an area composed of (2×2)=4 macroblocks 1 to 4. In this case, macroblocks 1 and 2 that have been processed are directly transferred to the encoder and encoded thereby according to JPEG. In contrast, macroblocks 3 and 4 are temporarily stored in the memory. In the next process unit (composed of macroblocks 5 to 8), macroblocks 5 and 6 that have been processed are directly transferred to the encoder and encoded thereby according to JPEG. Likewise, macroblocks 7 and 8 are temporarily stored in the memory. After macroblocks 1, 2, 5, and 6 that have been processed are encoded, macroblocks 3, 4, 7, and 8 that have been processed are read from the memory and transferred to the encoder.
When the unit of a picture process is an integer multiple of macroblocks (namely encoded blocks) and is different from the order defined in JPEG, it is necessary to store data of macroblocks to be encoded later in a memory. As a result, it is necessity to provide a temporary storage memory.
As an example of a picture process according to the present invention, there is a chromatic aberration correction process as shown in FIG. 4. A photographed picture P having a chromatic aberration is separated into a red picture Pr, a green picture Pg, and a blue picture Pb. A chromatic aberration occurs because the refractive index of a lens changes depending on the wavelength of light. Thus, since the magnitudes of primary color pictures of the same object vary, the sizes of the pictures vary. The resolutions of these primary color pictures are converted such that primary color pictures Pr′, Pb′, and Pg′ having the same size are formed. By combining these primary color pictures, a picture P′ whose chromatic aberration has been corrected is obtained. Thus, the present invention can be applied to a resolution conversion process.
FIG. 5 shows another picture process according to the present invention. In this process, a picture P1 that has a barrel-like distortion in the horizontal and vertical directions is enlarged in a first stage and thereby a picture P2 is obtained. In the first stage enlargement process, the picture P1 is enlarged in the horizontal direction. The enlargement factor is proportional to the distance from the center of the picture. The picture P2 is enlarged in a second stage and thereby a picture P3 is obtained. In the second stage enlargement process, the picture P2 is enlarged in the vertical direction. Thus, the enlargement factor is proportional to the distance from the center of the picture.
In the present invention, a rearrangement process of encoded blocks such as macroblocks is performed. A rearrangement process in the unit of a macro block is disclosed in Japanese Patent Application Laid-Open No. HEI 11-298878. In this document, after an MPEG stream is generated, it is rearranged in the unit of a macroblock such that the receiving side is prevented from watching a picture by decoding the MPEG stream.
As described above, in a picture process such as a picture size conversion process, when picture data are encoded in the encoding unit according to a compression-encoding process, it may be necessary to read picture data from a memory at high speed or use a memory having a large storage capacity. In the related art, after an MPEG stream is generated, a rearrangement process is performed therefor. In contrast, according to the present invention, a picture processing section encodes blocks in the order that is different from the regular order. Thereafter, the encoded blocks are rearranged in the regular order. This point is different from the related art.